Skip to content

Conversation

@dotnetCarpenter
Copy link
Contributor

By using the improved traverse function from #581 (comment)
and adding toString since the nodejs fs.readFile returns a Buffer and not a String.

// readFile :: FileName -> Task Error String

// firstWords :: String -> String
const firstWords = compose(intercalate(' '), take(3), split(' '), toString);

// tldr :: FileName -> Task Error String
const tldr = compose(map(firstWords), readFile);

traverse(Task.of, tldr, ['file1', 'file2']);
// Task(['hail the monarchy', 'smash the patriarchy']);

Before the traverse function threw a TypeError: f.traverse is not a function, on traverse(Task.of, tldr, ['file1', 'file2']);.

Thanks to @antonklimov.

By using the improved `traverse` function from MostlyAdequate#581 (comment)
and adding `toString` since the nodejs `fs.readFile` returns a Buffer and not a String.
@dotnetCarpenter
Copy link
Contributor Author

Blocks #607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant